package com.code2roc.fastface.model;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class Result implements Serializable {
    private int code;
    private String msg;
    private Map data = new HashMap();

    public Result() {
    }

    public int getCode() {
        return this.code;
    }

    public Result setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMsg() {
        return this.msg;
    }

    public Result setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Map getData() {
        return this.data;
    }

    public void setData(Map data) {
        this.data = data;
    }

    public Result add(String name, Object value) {
        if (this.data.containsKey(name)) {
            this.data.replace(name, value);
        } else {
            this.data.put(name, value);
        }

        return this;
    }

    public static Result okResult() {
        Result result = new Result();
        result.code = 0;
        result.msg = "success";
        return result;
    }

    public static Result errorResult() {
        Result result = new Result();
        result.code = -1;
        result.msg = "fail";
        return result;
    }
}
